import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, main, util, sim_items
from util import *

class Flare(sim_items.Armor, sim_items.LightSource):
    def __init__(self):
        bonuses = {
                'evMod': 0,
                'pvMod': 1,
        }

        sim_items.Armor.__init__(self, 
                'pair of moonstone gauntlets',    # name
                parole.map.AsciiTile('[', colors['PowderBlue']), # appearance
                3,          # weight (lbs)
                ['hands'],   # slot(s)
                6000,       # energy to wear
                bonuses)
        
        sim_items.LightSource.__init__(self,
                'pair of moonstone gauntlets',     #name
                50,     # layer
                parole.map.AsciiTile('[', colors['PowderBlue']),
                3,  # weight
                1000,   # light energy
                colors[random.choice(['Moccasin', 'LightBlue', 'PowderBlue', 'RoyalBlue'])],  # light color
                4.0,    # light intensity
                7*600000,  # burn time
                showBurnTime=True,                       
                dousable=False,
                litAdjective="shimmering",
                handsNeeded=0, # already takes a hand to ready as shield
                unidDescription="These gauntlets are set with a pair of flawless moonstones."
                                "The application of a rare alkaline will produce a lunar shine.")

        self.snuffable = False
        self.startIntensity = self.lightIntensity
        self.startBurnTime = self.burnTime
       
        
    def listen(self, event):
        super(Flare, self).listen(event)
        if event.id == 'burn' and event.args[0] is self:
            if not self.burnTime:
                return # we're already extinguished
            newIntensity = (float(self.burnTime) / self.startBurnTime) * \
                            self.startIntensity
            main.schedule.add(sim.Event('update light', main.schedule.time,
                (self, self.lightRGB, newIntensity), dests=[self]))    
        sim_items.Armor.listen(self, event)
        sim_items.LightSource.listen(self, event, superListen=False)
                
#========================================
thingClass = Flare 
